package com.wwj.study.interview.chapter2;

import java.io.*;

public class SerializableFileTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Order order=new Order();
        order.setOrderId(1);
        order.setOrderCode("1000");

        Member member=new Member();
        member.setId(1);
        member.setName("wwj");
        order.setMember(member);

        FileOutputStream fileOutputStream =new FileOutputStream("order");
        ObjectOutputStream outputStream=new ObjectOutputStream(fileOutputStream);
        outputStream.writeObject(order);

        FileInputStream fileInputStream = new FileInputStream("order");
        ObjectInputStream inputStream=new ObjectInputStream(fileInputStream);
        Order order1= (Order) inputStream.readObject();

        System.out.println(order);
        System.out.println(order1);
    }
}
